package com.zq.webserver.interfaces.user.controller;

import com.zq.webserver.interfaces.user.model.User;
import com.zq.webserver.interfaces.user.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by zhouquan on 2017/10/23.
 */
@RestController
public class UserController {

    private final static Logger log = LoggerFactory.getLogger(UserController.class);

    @Resource
    private UserService userService;

    @RequestMapping(value = "/user",method = RequestMethod.GET)
    public String addUser(User user){
//        logger.debug("这是 debug 测试");
//        logger.info("这是 info 测试");
//        logger.error("这是 error 测试", new Exception("这是error日志测试异常"));
        userService.addUser(user);
        return "ok";
    }

    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    public String deleteTest(@PathVariable int id){
        System.out.println(id);
        return "{\"key\":\"hellp\"}";
    }

    @RequestMapping(value = "/hello")
    public String test(){
        return "hello Mr.周";
    }
}
